package flex.cc.order.manage.enums;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import java.util.List;
import java.util.Map;

/**
*
* @author WANGCONG
* 2021年9月10日下午6:33:12
* @desc 下游服务商状态：01内勤受理02派单03救援师傅接单04改派05救援师傅到达现场开始作业06施救完成（拖车已拖至目的地）07师傅报备取消08任务结束
*/

public enum StatusEnum {
	/*
	//车服与下游状态码对应关系
    ONE("01", "内勤受理"),
    TWO("02", "派单"),
    THREE("03", "救援师傅接单"),
	FOUR("04", "改派"),
    FIVE("05", "救援师傅到达现场开始作业"),
    SIX("06", "施救完成（拖车已拖至目的地）"),
	SEVEN("07", "师傅报备取消"),
    EIGHT("08", "任务结束"),
	OTHER("09", "其它"),
	
	//下游与上游状态码对应关系
	UP_ONE("内勤受理", "READ"),
	UP_TWO("派单", "STARTED_DISPATCH"),
	UP_THREE("救援师傅接单", "DISPATCHED"),
	UP_FOUR("改派", "STARTED_DISPATCH"),
	UP_FIVE("救援师傅到达现场开始作业", "ARRIVED"),
	UP_SIX("施救完成（拖车已拖至目的地）", "COMPLETE");
	 */
	
	//车服与下游状态码对应关系
	//01内勤受理02派单03救援师傅接单04改派05救援师傅出发06救援师傅到达现场开始作业07施救完成（拖车已拖至目的地）08师傅报备取消09任务结束
    ONE("01", "内勤受理"),
    TWO("02", "派单"),
    THREE("03", "救援师傅接单"),
	FOUR("04", "改派"),
	FIVE("05", "救援师傅出发"),
	SIX("06", "救援师傅到达现场开始作业"),
	SEVEN("07", "施救完成（拖车已拖至目的地）"),
	EIGHT("08", "师傅报备取消"),
    NINE("09", "任务结束");
	
    String type;
    String name;

    StatusEnum(String type, String name) {
        this.type = type;
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public String getName() {
        return name;
    }

    public static String getName(String type) {
        for (StatusEnum ele : StatusEnum.values()) {
            if (type.equals(ele.getType())) {
                return ele.getName();
            }
        }
        return "未知";
    }

    public static StatusEnum getEnum(String type) {
        for (StatusEnum ele : StatusEnum.values()) {
            if (type.equals(ele.getType())) {
                return ele;
            }
        }
		return null;
    }

    public static List<Map<String, Object>> getList() {
        List<Map<String, Object>> list = Lists.newArrayList();
        for (StatusEnum ele : StatusEnum.values()) {
            Map<String, Object> map = Maps.newHashMap();
            map.put("key", ele.getType());
            map.put("value", ele.getName());
            list.add(map);
        }
        return list;
    }
}
